package com.hunter.robot;

import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * @Project:iwms
 * @Description: 鼠标模拟
 * @Author: Mr.Hunter
 * @Date:2022/6/5/15:32
 */
public class NewMouseRobot {
    private Robot mouseRobot = null;
    public NewMouseRobot() {
        try {
            mouseRobot = new Robot();
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }
    /**
 * @program com.hunter.robot.NewMouseRobot
 * @Description 获得s1，s2的值传化为整形作为坐标驱动鼠标模拟
 * @return
 * @Author Mr.Hunter
 * @Date 2022/6/6 14:16
 */
    public void XY(String s1,String s2) {

        mouseRobot.mouseMove(Integer.valueOf(s1),Integer.valueOf(s2));
        mouseRobot.mousePress(KeyEvent.BUTTON1_MASK);
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mouseRobot.mouseRelease(KeyEvent.BUTTON1_MASK);
    }
    public void delay(int milliseconds) {
        mouseRobot.delay(milliseconds);
    }

}